class IfLogin{
    constructor(url){
        // this.cart = document.querySelector(".cart");
        this.u1=url.url1;
        this.u2=url.url2;
        this.add=url.add;
        this.addEvent();
    }
    addEvent(){
        this.m = window.sessionStorage.getItem("userMsg");
        this.m = this.m ? JSON.parse(this.m) : {};
        var that=this;
        for(var i=0;i<this.add.length;i++){
            this.add[i].onclick=function(){
                if(that.m.user){
                    location.href=that.u1;
                }else{
                    location.href=that.u2;
                }
            }
        }
    }
}